package com.vigitae.sim;

import java.util.ArrayList;
import java.util.Random;

public class MainSend {
    public static void main(String[] args) {
        Long ii=0L;
        while (true){

            Random r = new Random();
            double s = r.nextGaussian();
            Integer num=(new Double(s*763)).intValue();

            try {
                send2Server(num);
                Thread.sleep(1000);
            }catch (Exception e){

            }
        }

    }
    public static void send2Server(Integer coreNum){
        ArrayList<Integer>curMacs=new ArrayList<>();
        for (int i = 0; i < coreNum; i++) {
            Random r = new Random();
            while (true){
                Integer ss=r.nextInt(1500);
                if (!curMacs.contains(ss)){
                    curMacs.add(ss);
                    break;
                }
            }

        }
        curMacs.parallelStream().map(it->GateWayMac.gateWayMacList.get(it))
                .forEach(mac->{


                    Random r = new Random();
                    Integer sensorType= GateWayMac.SeonsorType[r.nextInt(5)];
                    byte[] datas=getPackage(mac,sensorType);
                    //TODO tcp client 发送数据
                });
    }

    static byte[] getPackage(String gateWayMac,int type){
        //TODO 拼接消息包类型
        return null;
    }
}
